import {
  aJ as v,
  aK as y,
  q as r,
  p as L,
  ap as M,
  X as x,
  f as N,
  H as O,
  av as B,
  aw as T,
  k as V,
  m as F,
  l as R,
  az as H,
  as as s,
  at as b
} from "./index-30f27935.js";
const C = t => v.request("post", y("subject/list"), { data: t }),
  Y = t => v.request("post", y("subject/update"), { data: t }),
  P = t => v.request("post", y("subject/delete"), { data: t });
function K(t) {
  const d = r([]),
    n = r(!0);
  r({}), L();
  const p = r(1),
    f = r(10),
    h = r(),
    W = M("reload"),
    g = x({
      pageSize: 10,
      currentPage: 1,
      pageSizes: [10, 20, 30],
      total: 0,
      align: "right",
      background: !0,
      small: !1
    }),
    w = x({
      text: "正在加载第一页...",
      viewBox: "-10, -10, 50, 50",
      spinner: `
        <path class="path" d="
          M 30 15
          L 28 17
          M 25.61 25.61
          A 15 15, 0, 0, 1, 15 30
          A 15 15, 0, 1, 1, 27.99 7.5
          L 15 15
        " style="stroke-width: 4px; fill: rgba(0, 0, 0, 0)"/>
      `
    }),
    S = [
      {
        type: "selection",
        width: 55,
        align: "left",
        hide: ({ checkList: e }) => !e.includes("勾选列")
      },
      {
        label: "序号",
        type: "index",
        width: 70,
        hide: ({ checkList: e }) => !e.includes("序号列")
      },
      { label: "ID", prop: "id", minWidth: 50 },
      { label: "题目", prop: "subject_title", minWidth: 150 },
      {
        label: "类型",
        prop: "subject_type",
        minWidth: 100,
        formatter: ({ subject_type: e }) => {
          if (e == 1) return "选择题";
          if (e == 2) return "判断题";
        }
      },
      {
        label: "A选项",
        prop: "subject_a",
        minWidth: 150,
        formatter: ({ subject_a: e }) => e || "------"
      },
      {
        label: "B选项",
        prop: "subject_b",
        minWidth: 150,
        formatter: ({ subject_b: e }) => e || "------"
      },
      {
        label: "C选项",
        prop: "subject_c",
        minWidth: 150,
        formatter: ({ subject_c: e }) => e || "------"
      },
      {
        label: "D选项",
        prop: "subject_d",
        minWidth: 150,
        formatter: ({ subject_d: e }) => e || "------"
      },
      {
        label: "正确答案",
        prop: "subject_pick",
        minWidth: 50,
        formatter: ({ subject_pick: e }) => (e == 1 ? "对" : e == 2 ? "错" : e)
      },
      { label: "创建时间", prop: "create_time", minWidth: 150 },
      {
        label: "更新时间",
        prop: "update_time",
        minWidth: 150,
        formatter: ({ update_time: e }) =>
          e ||
          V(
            R("el-tag"),
            { class: "mx-1", type: "danger", effect: "light" },
            { default: () => [F("未更新")] }
          )
      },
      { label: "操作", fixed: "right", width: 200, slot: "operation" }
    ],
    j = N(() => [
      "!h-[20px]",
      "reset-margin",
      "!text-gray-500",
      "dark:!text-white",
      "dark:hover:!text-primary"
    ]);
  async function q(e) {
    H(e);
  }
  async function J(e) {
    const o = { id: e.id },
      l = JSON.stringify(o),
      u = { value: s.enc.Base64.stringify(s.enc.Utf8.parse(l)) },
      a = await P(u);
    a.code == 200
      ? (b("删除成功", { type: "success" }), W())
      : b(a.msg, { type: "error" });
  }
  function U() {}
  function z(e) {
    (f.value = e), i(void 0, e);
  }
  function I(e) {
    (p.value = e), i(e, void 0);
  }
  function _(e) {}
  function k(e) {
    (w.text = `正在加载第${e}页...`),
      (n.value = !0),
      B(600).then(() => {
        n.value = !1;
      });
  }
  async function A(e) {
    (n.value = !0), (h.value = e);
    const o = { page: p.value, pagesize: f.value, subject_type: h.value },
      l = JSON.stringify(o),
      u = { value: s.enc.Base64.stringify(s.enc.Utf8.parse(l)) },
      { data: a } = await C(u);
    (d.value = a.data),
      (g.total = a.total),
      setTimeout(() => {
        n.value = !1;
      }, 500);
  }
  async function i(e = p.value, o = f.value) {
    const l = { page: e, pagesize: o, subject_type: h.value },
      m = JSON.stringify(l),
      a = { value: s.enc.Base64.stringify(s.enc.Utf8.parse(m)) },
      c = await C(a);
    c.code === 200
      ? ((d.value = c.data.data),
        (g.total = c.data.total),
        setTimeout(() => {
          n.value = !1;
        }, 500))
      : b(c.msg, { type: "error" });
  }
  const D = e => {
    e && (e.resetFields(), location.reload());
  };
  return (
    O(() => {
      B().then(() => {
        const { setWatermark: e } = T(t.value.getTableDoms().tableWrapper);
        e("后台项目", {
          font: "16px Microsoft YaHei",
          globalAlpha: 0.8,
          forever: !0,
          width: 252,
          height: 80
        });
      }),
        i();
    }),
    {
      loading: n,
      columns: S,
      dataList: d,
      pagination: g,
      buttonClass: j,
      handleList: i,
      onSearch: A,
      resetForm: D,
      handleaddUser: U,
      handleUpdate: q,
      handleDelete: J,
      handleSizeChange: z,
      handleCurrentChange: I,
      handleSelectionChange: _,
      onCurrentChange: k
    }
  );
}
const $ = Object.freeze(
  Object.defineProperty({ __proto__: null, useRole: K }, Symbol.toStringTag, {
    value: "Module"
  })
);
export { $ as h, Y as q, K as u };
